import Request from '@/js/public/request'
import weshare from '@/js/public/weshare'
import '@/style/comm.css'
import './index.css'
import $ from 'jquery'
import Swiper from 'swiper';
import 'swiper/dist/css/swiper.min.css';
//图片
import pushDown from '../../imgs/pushDown.gif'
import pullDown from '../../imgs/pullDown.gif'

console.log(Request)

//	轮播
let mySwiper = new Swiper('.swiper-container', {
    autoplay: 2000,
    pagination: '.swiper-pagination'
})

//滚动
function scrollY(height,ul,time){
	ul.append('<li>'+ul.find('li').eq(0).html()+'</li>')
	height=height.height()
	var num=0
	setInterval(function(){
        num++;
		if(num===ul.find('li').length){
			num=1
			ul.css({
				marginTop:0
			})
		}		
		ul.animate({
			marginTop:-height*num
		},400)
	},time)
}
scrollY($('#scrollYBox'), $('#scrollYBox ul'), 2000)

//建议关闭
$('#suggest span').on('click',function(){
    $('#suggest').hide()
})

//获取用户手机号
let isCode = localStorage.getItem('serverZoomCode10086')
let code = GetQueryString('code')
let mobile
localStorage.setItem('serverZoomCode10086', code)

if (code && isCode != code) {
    $.post(Request + '/userInfoCtl/getuserinfo2', { 'code': code }, function (data) {
       try {
		let res=JSON.parse(data.data)
		mobile = res.telnum;
		localStorage.setItem('serverZoomMobile10086', mobile)
	   } catch (error) {
		$('.wxgz').show()
	   }     
    })
} else {
	mobile = localStorage.getItem('serverZoomMobile10086')
}

//新用户二维码关闭
$('.qrcodCclose').on('click',function(){
	$('.wxgz').hide()
})

//传入不同的问题
$(".clickProp li i").on('click',function(){
    window.location.href='./classify.html?answer='+this.id
})
//icon下拉
let pulldown=1
$('.pullDown i').click(function(){
   if(pulldown==1){
		$('.pullBox').animate({
			height:4.2+'rem'
		},200)
        $(this).css({"background":"url("+pushDown+")",'backgroundSize': '100% 100%' })
        pulldown=0
   }else{
		$('.pullBox').animate({
			height:2.8+'rem'
		},200)
    	$(this).css({"background":"url("+pullDown+")",'backgroundSize': '100% 100%'})
    pulldown=1
   } 
})

//快捷关注
$('#kjbd').on('click',function(){
    $('.wxgz').show()
})
$('.qrcodCclose').on('click',function(){
    $('.wxgz').hide()
})
//分享引导
$('#shareGuide').on('click',function(){
	$('.shareBox').show()
})
$('.shareBox').on('click',function(){
	$('.shareBox').hide()
})

function GetQueryString(name) {
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
	var r = window.location.search.substr(1).match(reg);
	if (r != null) return unescape(r[2]);
	return null;
}
//分享
weshare('https://www.shandong10086.com/zhengqifuwu/userFeedbackCtl/index')